package com.itheima.d11_csbdemo;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class CsbDemo {
    public static void main(String[] args) {
        try(
                FileReader fr = new FileReader("day06-file-io\\src\\com\\itheima\\testcsb.txt");
                FileWriter fw = new FileWriter("day06-file-io\\src\\com\\itheima\\testcsb3.txt");
                BufferedReader br = new BufferedReader(fr);
                BufferedWriter bw = new BufferedWriter(fw);
        ){
            ArrayList<String> list = new ArrayList<>();
            String line;
            while((line = br.readLine()) != null){
               list.add(line);
            }
            //默认升序
            Collections.sort(list);
            for (String s : list) {
                bw.write(s);
                bw.newLine();
            }

        }catch (Exception e){
            e.printStackTrace();
        }

    }
}
